//
//  HRZUserManager.h
//  EMarket
//
//  Created by 石头 on 2018/10/9.
//  Copyright © 2018 好日子. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "HRZUserInfo.h"

typedef NS_ENUM(NSInteger, UserLoginType) {
    kUserLoginTypeUnKnow = 0,   //未知
    kUserLoginTypePwd,          // 账号登陆
    kUserLoginTypeQQ,           // QQ登陆
    kUserLoginTypeWeChat,       // 微信登陆
    kUserLoginTypeWeibo,        // 微博登陆
};

typedef void (^loginBlock)(BOOL isSuccess, NSString *des);

#define isLogin [UserManager sharedUserManager].isLogined
#define curUser [UserManager sharedUserManager].curUserInfo
#define userManager [UserManager sharedUserManager]


/** 用户管理 */
@interface HRZUserManager : NSObject

// 单例
SINGLETON_FOR_HEADER(HRZUserManager)

@property (nonatomic, strong) HRZUserInfo *curUserInfo;
@property (nonatomic, assign) UserLoginType loginType;
@property (nonatomic, assign) BOOL isLogined;

#pragma mark - ----  registerMethod  ----


/**
 获取验证码

 @param phoneNum 手机号
 */
- (void)userReciveVerifyNumBySendPhoneNumber:(NSString *)phoneNum;

/**
 手机注册

 @param phone 手机号
 @param password 密码
 @param completion 回调
 */

/**
 账号注册

 @param phone 手机号
 @param password 密码
 @param verifyNum 验证码
 @param completion 回调   
 */
- (void)userRegisterByPhone:(NSString *)phone password:(NSString *)password verifyNum:(NSString *)verifyNum completion:(loginBlock)completion;

#pragma mark - ----------  loginMethod  ----------

/**
 三方登录

 @param loginType 登录方式
 @param complete 回调
 */
- (void)loginWithThirdType:(UserLoginType)loginType complete:(loginBlock)complete;


/**
 账户密码登录

 @param username 账户
 @param password 密码
 @param completion 回调
 */
- (void)loginWithUsername:(NSString *)username password:(NSString *)password completion:(loginBlock)completion;

/**
 自动登录

 @param completion 回调
 */
- (void)autoLoginToServer:(loginBlock)completion;

/**
 用户登出

 @param completion 回调
 */
- (void)logout:(loginBlock)completion;

/**
 加载缓存数据
 */
- (BOOL)loadUserInfo;


@end
